package com.lz.sports.adapter

import android.view.LayoutInflater
import android.view.ViewGroup
import android.widget.TextView
import androidx.recyclerview.widget.RecyclerView
import com.lz.library.adapter.SimpleViewHolder
import com.lz.library.extension.APP
import com.lz.sports.R
import com.lz.sports.utils.DateUtils

class ScoreFootAdapter : RecyclerView.Adapter<SimpleViewHolder>() {

    private var time: Long = 0L

    override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): SimpleViewHolder {
        return SimpleViewHolder(LayoutInflater.from(APP).inflate(R.layout.item_score_footer, parent, false))
    }

    override fun onBindViewHolder(holder: SimpleViewHolder, position: Int) {
        holder.getView<TextView>(R.id.tv_time).text = DateUtils.format(time)
    }

    override fun getItemCount(): Int = if (time > 0) 1 else 0

    fun setSureTime(time: Long) {
        this.time = time
        notifyDataSetChanged()
    }
}